package ioc14;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Author:shixiaojun@itany.com
 * Date:2022/3/7 13:38
 * Version:1.0-SNAPSHOT
 */
public class Test {

    public static void main(String[] args) throws ParseException {
        ApplicationContext ac = new ClassPathXmlApplicationContext("ioc14/spring.xml");
        SomeService someService = (SomeService) ac.getBean("someService");
        SomeService someService2 = (SomeService) ac.getBean("someService");
        someService.doSome();
        System.out.println(someService);
        System.out.println(someService2);

        // 练习
        // 生产一个日期对象的过程
        // 要求:将一个字符串转换成指定的日期
        // 其中字符串分为三块:年、月、日
        // 这三个字符串的值交给Spring容器进行注入
//        String year = "";
//        String month = "";
//        String day = "";
//        Date date = new SimpleDateFormat("yyyy-MM-dd").parse(year+"-"+month+"-"+day);
        Date date = (Date) ac.getBean("date");
        System.out.println(date);
    }

}
